﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="codeSnippetContent">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" name="item" type="itemType" minOccurs="0">
                </xs:element>
            </xs:sequence>
        </xs:complexType>

        <!--Make the id of each item tag unique -->
        <xs:unique name="item">
            <xs:selector xpath=".//item" />
            <xs:field xpath="@id" />
        </xs:unique>
    </xs:element>
    
    <xs:complexType name="itemType">
        <xs:sequence>
            <xs:element maxOccurs="unbounded" name="sampleCode" type="sampleCodeType" minOccurs="1">
            </xs:element>
        </xs:sequence>
        <xs:attribute name="id" type="IdType" use="required" />
    </xs:complexType>
    
    <xs:simpleType name="IdType">
        <xs:restriction base="xs:string">
            <xs:pattern value="^[^#\a\b\f\n\r\t\v]+#\w+$" />
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="languageType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="CSharp" />
            <xs:enumeration value="VisualBasic" />
            <xs:enumeration value="VBScript" />
            <xs:enumeration value="VisualBasicAndCSharp" />
            <xs:enumeration value="ManagedCPlusPlus" />
            <xs:enumeration value="JSharp" />
            <xs:enumeration value="JScript" />
            <xs:enumeration value="XmlLang" />
            <xs:enumeration value="Html" />
            <xs:enumeration value="Xaml" />
        </xs:restriction>
    </xs:simpleType>
    
    <xs:complexType name="sampleCodeType">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="language" type="languageType" use="required" />
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:schema>